﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text.RegularExpressions;
using System.Collections;
/// <summary>
///Verification 的摘要说明
/// </summary>
namespace Check
{
    public static class Verification
    {
        //判断是否为手机号码
        public static bool IsMobileNum(string _value)
        {
            string str_0 = "^(13[0-9]|15[0-9]|18[0-9])\\d{8}$";
            if (_value.Length > 11)
            {
                return false;
            }
            return Regex.IsMatch(_value, str_0);
        }

        /// <summary>
        /// 判断是否为电话号码
        /// </summary>

        public static bool IsPhoneNum(string _value)
        {
            //string str = "0123456789-";
            string str = "^(([0\\+]\\d{2,3}-)?(0\\d{2,3})-)(\\d{7,8})(-(\\d{3,}))?$";
            if (string.IsNullOrEmpty(_value))
            {
                return false;
            }
            return Regex.IsMatch(_value, str);
            //else
            //{
            //    foreach (var c in _value)
            //    {
            //        if (str.IndexOf(c) == -1)
            //        {
            //            return false;
            //        }
            //    }
            //}
            //return true;
        }


        /// <summary>
        /// 是否是特殊字符
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static bool IsTszfc(string value)
        {
            string str = "~!@#$%^&*()_+{}|[]\\:\";'<>,.?/~-=|"+"  ";

            IEnumerator ie = value.GetEnumerator();
            while (ie.MoveNext())
            {
               
                  if(str.Contains((char)ie.Current))
                  {
                      return false;
                  }
            } 


            //foreach (var c in value)
            //{
            //    if (str.IndexOf(c) == -1)
            //    {
                   
            //        return false;
            //    }
               
            //}

            //if (value.ToLower().IndexOf("and") == -1 || value.ToLower().IndexOf("or") == -1)
            //{
            //    return false;
            //}
            return true;
        }

    }
}